<?php defined('_JEXEC') or die('Restricted access'); ?>

<?php JHTML::_('behavior.tooltip'); ?>

<?php
	$cid = JRequest::getVar( 'cid', array(0) );//获取页面变量
	$edit		= JRequest::getVar('edit',true);
	$text = intval($edit) ? JText::_( 'Edit' ) : JText::_( 'New' );

	JToolBarHelper::title( JText::_( '前台用户' ) . ': <small><small>[ '. $text .' ]</small></small>' , 'user.png' );
	JToolBarHelper::save();
	JToolBarHelper::apply();
	if ( $edit ) {
		// for existing items the button is renamed `close`
		JToolBarHelper::cancel( 'cancel', 'Close' );
	} else {
		JToolBarHelper::cancel();
	}
	//JToolBarHelper::help( 'screen.users.edit' );
	//$cparams = JComponentHelper::getParams ('com_media');
?>


<script language="javascript" type="text/javascript">
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
		var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&]", "i");

		// do field validation
		if (trim(form.grade.value) == "") {
			alert( "<?php echo JText::_( '请输入用户等级', true ); ?>" );
		} else if (form.score.value == "") {
			alert( "<?php echo JText::_( '请输入用户积分', true ); ?>" );
		} else {
			submitform( pressbutton );
		}
	}

	function gotocontact( id ) {
		var form = document.adminForm;
		form.contact_id.value = id;
		submitform( 'contact' );
	}
</script>
<form action="index.php" method="post" name="adminForm" autocomplete="off">
	<div class="col width-45">
		<fieldset class="adminform">
		<legend><?php echo JText::_( '前台用户基本资料' ); ?></legend>
			<table class="admintable" cellspacing="1">
				<tr>
					<td width="150" class="key">
						<label for="nickname">
							<?php echo JText::_( 'nickname' ); ?>
						</label>
					</td>
					<td>
						<?php echo $this->user->nickname; ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="fullname">
							<?php echo JText::_( 'fullname' ); ?>
						</label>
					</td>
					<td>
						<?php echo $this->user->fullname; ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="email">
							<?php echo JText::_( 'Email' ); ?>
						</label>
					</td>
					<td>
						<?php echo $this->user->email; ?>
					</td>
				</tr>
				<tr>
					<td valign="top" class="key">
						<label for="viptype">
							<?php echo JText::_( 'vip类型设置' ); ?>
						</label>
					</td>
					<td>
						<?php echo $this->lists['viptype']; ?>
					</td>
				</tr>
				
				<?php if ($this->me->authorize( 'com_users', 'block user' )) { ?>
				<tr>
					<td class="key">
						<?php echo JText::_( '封禁用户' ); ?>
					</td>
					<td>
						<?php echo $this->lists['block']; ?>
					</td>
				</tr>
				
				<?php } if( $this->user->id ) { ?>
				<tr>
					<td class="key">
						<?php echo JText::_( 'Register Date' ); ?>
					</td>
					<td>
						<?php echo JText::_( $this->user->created ); ?>
					</td>
				</tr>
				
				<?php } ?>
			</table>
		</fieldset>
	</div>
    <div class="col width-55">
		<fieldset class="adminform">
		<legend><?php echo JText::_( '前台用户拓展资料' ); ?></legend>
			<table class="admintable">
				<tr>
					<td width="150" class="key">
						<label for="grade">
							<?php echo JText::_( '等级' ); ?>
						</label>
					</td>
					<td>
						<input type="text" name="grade" id="grade" class="inputbox" size="40" value="<?php echo $this->user->grade; ?>" autocomplete="off" />
					</td>
				</tr>
				<tr>
					<td width="150" class="key">
						<label for="score">
							<?php echo JText::_( '积分' ); ?>
						</label>
					</td>
					<td>
						<input type="text" name="score" id="score" class="inputbox" size="40" value="<?php echo $this->user->score; ?>" autocomplete="off" />
					</td>
				</tr>
				<tr>
					<td width="150" class="key">
						<label for="name">
							<?php echo JText::_( '跟随者' ); ?>
						</label>
					</td>
					<td>
						<?php echo $this->follow->followers; ?>
					</td>
				</tr>
				<tr>
					<td width="150" class="key">
						<label for="name">
							<?php echo JText::_( '发送消息数' ); ?>
						</label>
					</td>
					<td>
						<?php echo $this->message->num; ?>
					</td>
				</tr>
				<tr>
					<td width="150" class="key">
						<label for="name">
							<?php echo JText::_( '封禁消息数' ); ?>
						</label>
					</td>
					<td>
						<?php echo $this->messageban->num; ?>
					</td>
				</tr>
				<tr>
					<td width="150" class="key">
						<label for="name">
							<?php echo JText::_( '用户被举报次数' ); ?>
						</label>
					</td>
					<td>
						<?php echo $this->userrep->num; ?>
					</td>
				</tr>
				<tr>
					<td width="150" class="key">
						<label for="name">
							<?php echo JText::_( '消息被举报次数' ); ?>
						</label>
					</td>
					<td>
						<?php echo $this->messagerep->num; ?>
					</td>
				</tr>
			</table>
		</fieldset>
	</div>
	
	<div class="clr"></div>

	<input type="hidden" name="id" value="<?php echo $this->user->id; ?>" />
	<input type="hidden" name="cid[]" value="<?php echo $this->user->id; ?>" />
	<input type="hidden" name="option" value="com_users" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="contact_id" value="" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>
